import {ref, onMounted, onUnmounted} from 'vue'
import {useEventListener} from './event.js'

export const useMouse = () => {
	const x = ref(0)
	const y = ref(0)
	const update = (e) => {
		x.value = e.pageX
		y.value = e.pageY
	}
	// useEventListener(window, 'mousemove', update)
	onMounted(() => {
		window.addEventListener('mousemove', update)
	})
	onUnmounted(() => {
		window.removeEventListener('mousemove', update)
	})
	return {
		x,
		y
	}
}